DESTDIR = 
CC = @CC@
INSTALL = @INSTALL@
ACM_HOME = @ACM_HOME@
BINDIR = $(ACM_HOME)/bin
LIBDIR = $(ACM_HOME)/lib
JAVA_HOME = @JAVA_HOME@
OS_NAME = @OS_NAME@
OS_ARCH = @OS_ARCH@
LIB_DL = @LIB_DL@
JDKLIB = -I$(JAVA_HOME)/include/
JDKOSLIB = -I$(JAVA_HOME)/include/$(OS_NAME)/
JVMLINK = -L$(JAVA_HOME)/jre/lib/$(OS_ARCH)/server

all:
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libacm2seq.c getJNIOption.c -o libacm2seq.so -ljvm 
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libseq2acm.c getJNIOption.c -o libseq2acm.so -ljvm
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libcobpp.c   getJNIOption.c -o libcobpp.so -ljvm
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libsqlnetserver.c   getJNIOption.c -o libsqlnetserver.so -ljvm
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libcob2meta.c   getJNIOption.c -o libcob2meta.so -ljvm
	$(CC) $(JDKLIB) $(JDKOSLIB) $(JVMLINK) -shared -fPIC -Wall -v libmeta2sql.c   getJNIOption.c -o libmeta2sql.so -ljvm
	$(CC)                                                -Wall -v acm2seq.c -o acm2seq $(LIB_DL)
	$(CC)                                                -Wall -v seq2acm.c -o seq2acm $(LIB_DL)
	$(CC)                                                -Wall -v cobpp.c   -o cobpp $(LIB_DL)
	$(CC)                                                -Wall -v sqlnetserver.c -o sqlnetserver $(LIB_DL)
	$(CC)                                                -Wall -v cob2meta.c   -o cob2meta $(LIB_DL)
	$(CC)                                                -Wall -v meta2sql.c   -o meta2sql $(LIB_DL)

install:
	mkdir $(BINDIR)
	$(INSTALL) acm2seq            $(BINDIR)/
	$(INSTALL) seq2acm            $(BINDIR)/
	$(INSTALL) cobpp              $(BINDIR)/
	$(INSTALL) sqlnetserver       $(BINDIR)/
	$(INSTALL) cob2meta           $(BINDIR)/
	$(INSTALL) meta2sql           $(BINDIR)/
	$(INSTALL) libacm2seq.so      $(LIBDIR)/
	$(INSTALL) libseq2acm.so      $(LIBDIR)/
	$(INSTALL) libcobpp.so        $(LIBDIR)/
	$(INSTALL) libsqlnetserver.so $(LIBDIR)/
	$(INSTALL) libcob2meta.so     $(LIBDIR)/
	$(INSTALL) libmeta2sql.so     $(LIBDIR)/

deinstall:
	rm $(BINDIR)/acm2seq
	rm $(BINDIR)/seq2acm
	rm $(BINDIR)/cobpp
	rm $(BINDIR)/sqlnetserver
	rm $(BINDIR)/cob2meta
	rm $(BINDIR)/meta2sql
	rm -rv $(BINDIR)
	rm $(LIBDIR)/libacm2seq.so
	rm $(LIBDIR)/libseq2acm.so
	rm $(LIBDIR)/libcobpp.so
	rm $(LIBDIR)/libsqlnetserver.so
	rm $(LIBDIR)/libcob2meta.so
	rm $(LIBDIR)/libmeta2sql.so

clean:
	rm libacm2seq.so
	rm libseq2acm.so
	rm libcobpp.so
	rm libsqlnetserver.so
	rm libcob2meta.so
	rm libmeta2sql.so
	rm acm2seq
	rm seq2acm
	rm cobpp
	rm sqlnetserver
	rm cob2meta
	rm meta2sql
